# 读取图像
import os

from PIL import Image
from matplotlib import pyplot as plt
from src.color.color import label2color
from src.config.config import DATA_ROOT

image_path = os.path.join(DATA_ROOT, 'images', 'AJ1_100.jpg')
label_path = os.path.join(DATA_ROOT, 'labels', 'AJ1_100.png')

image = Image.open(image_path)
lable = Image.open(label_path)
print(f"image path: {image_path}, image size: {image.size}")
print(f"label path: {label_path}, label size: {lable.size}")

# 可视化
fig, axes = plt.subplots(1, 2, figsize=(1 * 5, 1 * 5))
fig.subplots_adjust(top=1, bottom=0, left=0, right=1, hspace=0.01, wspace=0.01)
axes[0].imshow(image)
axes[0].axis("off")
axes[0].set_title("image")
axes[1].imshow(label2color(lable))
axes[1].axis("off")
axes[1].set_title("to color label")
plt.show()
